<template name="zTimeCreate">
	<view class="center-view">
		<view class="option-item">
			<text class="item-name">问题</text>
			<input class="item-content theme-input" style="width:70%" v-model="que"/>
		</view>
		<view class="option-item">
			<text class="item-name">年</text><switch :checked="year" color="green" @change="changeYear"  class="item-content" style="margin-top:-10upx" />
		</view>
		<view class="option-item">
			<text class="item-name">月日</text><switch :checked="month" color="green" @change="changeMonth" class="item-content" style="margin-top:-10upx" />
		</view>
		<view class="option-item">
			<text class="item-name">时</text><switch :checked="hour" color="green" @change="changeHour" class="item-content" style="margin-top:-10upx" />
		</view>
		<view class="option-item">
			<text class="item-name">分</text><switch :checked="minute" color="green" @change="changeMinute" class="item-content" style="margin-top:-10upx" />
		</view>
		<view class="option-item">
			<text class="item-name">是否为时间区间</text><switch :checked="interval" color="green" @change="changeInterval" class="item-content" style="margin-top:-10upx" />
		</view>
	</view>
</template>
<script>
	export default {
		name : "zTimeCreate",
		data() {
			return {
				que : "",
				precision : 32,
				year : true,
				month : true,
				day : true,
				hour : true,
				minute : true,
				interval : false
			};
		},
		props : {
		},
		created : function(e){
			
		},
		methods: {
			get : function(id){
				if(this.que == ''){
					uni.showModal({
						title : '错误',
						content : '问题不可为空',
						showCancel : false
					})
					return null;
				}
				var res = {}
				res['question'] = this.que;
				res['key'] = 'q' + id;
				res['type'] = 'ztime';
				var answer = {};
				var precision = 0;
				if(this.year) precision += 16;
				if(this.month) precision += 12;
				if(this.hour) precision += 2;
				if(this.minute) precision += 1;
				if(precision == 0 || precision == 13 || precision == 17 || precision == 18 || precision == 19 || precision == 29){
					uni.showModal({
						title : '错误',
						content : '不合理的时间',
						showCancel : false
					})
					return null;
				}
				answer['precision'] = precision;
				answer['interval'] = this.interval;
				res['answer'] = answer;
				this.que = '';
				return res;
			},
			changeInterval : function(e){
				this.interval = e.detail.value;
			},
			changeYear : function(e){
				this.year = e.detail.value;
			},
			changeMonth : function(e){
				this.month = e.detail.value;
			},
			changeHour : function(e){
				this.hour = e.detail.value;
			},
			changeMinute : function(e){
				this.minute = e.detail.value;
			}
		}
	}
</script>

<style>
	@import "../../../common/zcss.css";
	@import "./creator.css";
</style>
